package edu.mcw.rgd.clinminer.umls.domain;

import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.eclipse.persistence.annotations.ReadOnly;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord(persistenceUnit = "persistenceUnitUMLS", versionColumn = "")
@ReadOnly
@NamedQueries({ @NamedQuery(name = "findDefinitions", query = "SELECT DISTINCT D.def FROM MrDef D WHERE D.aui=:aui ORDER BY D.def") })
public class MrDef {
	@Id
	@Column(name = "ATUI")
	private String atui;

	@Column(name = "CUI")
	private String cui;

	@Column(name = "AUI")
	private String aui;

	@Column(name = "SAB")
	private String sab;

	@Column(name = "DEF")
	private String def;

	public static Collection<String> getDefinitionsForAUI(String aui) {
		List<String> result = entityManager()
				.createNamedQuery("findDefinitions", String.class)
				.setParameter("aui", aui).getResultList();
		return result;
	}
}
